package com.example;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;

public class Activity_01 extends Activity {

    private ProgressBar horizontalProgress = null;
    private ProgressBar defaultProgress = null;
    private Button button = null;

    private int proCount = 0;
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // 根据id获得view对象
        horizontalProgress = (ProgressBar)findViewById(R.id.horizontalProgress);
        defaultProgress = (ProgressBar)findViewById(R.id.defaultProgress);
        button = (Button)findViewById(R.id.button);

        button.setOnClickListener(new ButtonListener());
//      System.out.println(horizontalProgress.getMax());
        System.out.println("SSSSSSSSSSS");
    }

    class ButtonListener implements View.OnClickListener{
        @Override
        public void onClick(View view) {

            if(proCount == 0){
                horizontalProgress.setVisibility(View.VISIBLE);
                defaultProgress.setVisibility(View.VISIBLE);
            } else if (proCount < horizontalProgress.getMax()){
                horizontalProgress.setProgress(proCount);
                // 设置第二进度条
                horizontalProgress.setSecondaryProgress(proCount + 10);
                // 默认进度条不能显示进度的
                defaultProgress.setProgress(1);
            } else{
                horizontalProgress.setVisibility(View.GONE);
                defaultProgress.setVisibility(View.GONE);
                proCount = -10;
            }

            proCount +=10;
        }
    }


}
